package com.guard.agent.plugin.springboot;

import com.google.auto.service.AutoService;
import com.guard.agent.plugin.IPlugin;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

import static net.bytebuddy.matcher.ElementMatchers.*;

@AutoService(IPlugin.class)
public class SpringBootPlugin implements IPlugin {

    @Override
    public String namespace() {
        return "spring-boot";
    }

    @Override
    public ElementMatcher<? super TypeDescription> typeMatcher() {
        return isAnnotatedWith(named("org.springframework.boot.autoconfigure.SpringBootApplication"));
    }

    @Override
    public ElementMatcher<? super MethodDescription> methodMather() {
        return isMain();
    }

    @Override
    public Class getAdvice() {
        return SpringBootAdvice.class;
    }

}
